package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class ReflectDemo5 {
    public static void main(String[] args) throws Exception {
        Class cla = Class.forName("reflect.Person");

        Constructor c = cla.getConstructor(String.class);
        Object obj = c.newInstance("李斯");

        Method method = cla.getMethod("say",String.class);
        method.invoke(obj,"大家好！");

        Method method1 = cla.getMethod("say", String.class, int.class) ;
        method1.invoke(obj,"大家好！",5);
    }
}
